// 语言包
var chi = require('../../utils/Chinese.js')
var eng = require("../../utils/English.js")
//获取应用实例
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        language: '',
        // 语言包对象
        content: '',
        // app返回发票类型
        type:'',
        personal: true,
        company: false,
        color: '#0E3092',
        color1: '#d2d2d2',

    },

    // 提交表单
    perSubmit:function (e) {
        console.log('个人form发生了submit事件，携带数据为：', e.detail.value)
      },
    comSubmit: function (e) {
        console.log('单位form发生了submit事件，携带数据为：', e.detail.value)
      },
    on: function () {
        let that = this
        that.setData({
            language: app.data.language,
        })
        var lastLanuage = that.data.language
        if (lastLanuage == 'zh_CN') {
            that.setData({
                content: chi.content,
                type:'个人'
            })
            wx.setNavigationBarTitle({
                title: '发票信息'
            })
        } else if (lastLanuage == 'zh_EN') {
            that.setData({
                content: eng.content,
                type:'personal'
            })
            // 修改导航标题
            wx.setNavigationBarTitle({
                title: 'Invoice Information'
            })
        }
    },
    // 页面跳转

    personal: function () {
        let that = this
        var lastLanuage = that.data.language
        that.setData({
            personal: true,
            company: false,
            color: '#0E3092',
            color1: '#d2d2d2'
        })
        if (lastLanuage == 'zh_CN') {
            that.setData({
                type:'个人'
            })
        } else if (lastLanuage == 'zh_EN') {
            that.setData({
                type:'personal'
            })
        }
    },
    company: function () {
        let that = this
        that.setData({
            personal: false,
            company: true,
            color: '#d2d2d2',
            color1: '#0E3092'
        })
        var lastLanuage = that.data.language
        if (lastLanuage == 'zh_CN') {
            that.setData({
                type:'单位'
            })
        } else if (lastLanuage == 'zh_EN') {
            that.setData({
                type:'company'
            })
        }
    },
    bbtn:function(){
        // 将发票类型存储到 app中
        var that = this
        app.data.invoice_true = that.data.type
        wx.redirectTo({
          url: '../order_infor/order_infor',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this
        that.on()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let that = this
        that.on()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})